#include "widget.h"
#include "ui_widget.h"
#include <QButtonGroup>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 对多个选项进行分组，在组内利用radiobutton的排他性来进行选择
    QButtonGroup* group1 = new QButtonGroup(this);
    QButtonGroup* group2 = new QButtonGroup(this);

    group1->addButton(ui->radioButton);
    group1->addButton(ui->radioButton_2);
    group1->addButton(ui->radioButton_3);

    group2->addButton(ui->radioButton_4);
    group2->addButton(ui->radioButton_5);
    group2->addButton(ui->radioButton_6);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_radioButton_clicked()
{
    result = "";
    result = ui->radioButton->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}

void Widget::on_radioButton_2_clicked()
{
    result = "";
    result = ui->radioButton_2->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}

void Widget::on_radioButton_3_clicked()
{
    result = "";
    result = ui->radioButton_3->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}

void Widget::on_radioButton_4_clicked()
{
    result += ui->radioButton_4->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}

void Widget::on_radioButton_5_clicked()
{
    result += ui->radioButton_5->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}


void Widget::on_radioButton_6_clicked()
{
    result += ui->radioButton_6->text() + " ";
    ui->label->setText("选择要吃的食物: " + result);
}



